package com.remist.web.action;

import java.util.List;

import com.remist.common.PaginationSupport;
import com.remist.model.Member;
import com.remist.service.MemberService;

public class ManagerMemberAction extends BaseAction {
	private List<Member> members;
	private MemberService memberService;
	private Member member;
	public void setMemberService(MemberService memberService) {
		this.memberService = memberService;
	}
	public Member getMember() {
		return member;
	}
	public void setMember(Member member) {
		this.member = member;
	}
	public List<Member> getMembers() {
		return members;
	}

	public void setMembers(List<Member> members) {
		this.members = members;
	}

	public String execute() throws Exception {
		return SUCCESS;
	}
	public String beforeUpdate() throws Exception {
		member =  memberService.getMemberById(member);
		return SUCCESS;
	}
	
	public String update() throws Exception {
		int memberType = member.getMemberType();
		member = memberService.getMemberById(member);
		member.setMemberType(memberType);
		memberService.updateMember(member);
		return SUCCESS;
	}
	
	public String delete() throws Exception {
		memberService.deleteMember(member);
		return SUCCESS;
	}
	
	public String listMember() throws Exception {
		int pageSize =1;// Constant.PAGE_SIZE;
		int startIndex = super.getCurrentPage();
		PaginationSupport ps = memberService.getPaginationSupport(pageSize, startIndex);
		members = ps.getItems();
		super.setPageInfo(ps); 
		return SUCCESS;
	}

	
}
